﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Org.Mentalis.Utilities;

namespace MulticastTV
{
    public partial class CancelActionForm : Form
    {
        Timer countdown = new Timer();
        int start = 15;
        int action = 0;
        string info = "";
        
       // !!! HARDCODED TRANSLATION - Use MLmessages.resx
        
        public CancelActionForm(int act)
        {
            InitializeComponent();
            action = act;
            if (Properties.Settings.Default.language == "Slovenian")
            {
                if (act == 1)
                    info = "Stanje pripravljenosti čez:";
                if (act == 2)
                    info = "Stanje mirovanja čez:";
                if (act == 3)
                    info = "Računalnik se bo ugasnil čez:";
            }
            else
            { 
                if (act == 1)
                    info = "System will go into standby mode";
                if (act == 2)
                    info = "System will go into hibernate mode in";
                if (act == 3)
                    info = "System will shutdown in";
            }
        }

        private void CancelActionForm_Load(object sender, EventArgs e)
        {
            label1.Text = info;
            countdown.Interval = 1000;
            countdown.Tick+=new EventHandler(countdown_Tick);
            countdown.Start();
        }

        private void countdown_Tick(Object sender, EventArgs e)
        {
            start--;
            label2.Text = start.ToString()+" s";
            if (start == 0)
            {
                // start action 
                if (action == 1)
                {
                    //standby
                    WindowsController.ExitWindows(RestartOptions.Suspend, false);
                    this.Close();

                }
                else if (action == 2)
                {
                    //hibernate
                    WindowsController.ExitWindows(RestartOptions.Hibernate, true);
                    this.Close();
                }
                else if (action == 3)
                {
                    //shutdown
                    WindowsController.ExitWindows(RestartOptions.ShutDown, false);
                    this.Close();

                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
